<html>
<!-- (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP -->
<head>
<title>Jena2 Microsoft SQL Server HowTo</title>
<link href="../styles/doc.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>HowTo Use Microsoft SQL Server Database System with Jena2</h1>

<h2>What is Microsoft SQL Server?</h2>

<p><i>Microsoft SQL Server</i> refers to a range of database servers available from Microsoft Corporation
for use under the Windows operating system. Jena has been tested with Microsoft 
SQL Server 2005 Express, Microsoft SQL Server 2000 (Enterprise Edition), and with the Microsoft SQL Server 2000 Desktop Edition (MSDE) Release A.</p>
<h2>Download and Installation of SQL Server Express
</h2>
<p>Download and install Microsoft SQL Server 2005 Express SP1. It is convenient 
to install the server manager as well.</p>
<p>Installation will need to include enabling TCP/IP access via the Microsoft 
Surface Area configuration tool.</p>

<p>Install a JDBC driver. The Microsoft JDBC driver has been tested with Jena. All 
that is required is the JAR file, so you may choose to install the .msi file or 
download download the Unix version (.tar.gz) and just pull the jar out of it and 
use that on WindowsXP.</p>
<p>
In addition there is an open source driver compatible with SQL Server available from 
<a href="http://jtds.sourceforge.net/">http://jtds.sourceforge.net/</a>.
</p>

<p>Ensure the JDBC driver is on your application classpath.</p>
<p>The URL is like (in Java):</p>
<pre>
String jdbcURL =&quot;jdbc:sqlserver://localhost\\SQLExpress;database=jenatest&quot; ;
  //** Note the \\ - that is Java escape becoming a single \
  //** Note: assumes it is not the default instance
  //  (example shown is the install default which is a named instance of SQLExpress)
</pre>

<p>See this <a href="http://blogs.msdn.com/angelsb/archive/2005/10/20/483206.aspx">Microsoft blog</a> for details.</p>

<ol>
  <li>Enable TCP/IP. Forget to do it when you installed? Run the SQL Server Area Configuration tool / Services and Connections</li>
  <li>Ensure your firewall isn't blocking port 1433</li>
  <li>Make sure the SQL Server Browser is running or automatic : SQL Server Configuration Manager</li>
</ol>

<p>Create a user.&nbsp; Create a database.&nbsp; Allow the user to access the 
database with at least these permissions:</p>
<ul>
  <li>db_datareader</li>
  <li>db_datawriter</li>
  <li>db_ddlwriter (gives the ability to create SQL tables)</li>
</ul>
<p>Persistent models are <a href="creating-db-models.html">created</a> in the 
usual way: </p>
<blockquote>
  <ol>
    <li>Load the JDBC driver. This enables the Jena program to communicate with 
    the database instance.</li>
    <li>Create a database connection. This creates a Java object for a database 
    connection.</li>
    <li>Create a ModelMaker for the database</li>
    <li>Create a Model for existing or new data.</li>
  </ol>
</blockquote>

<p>
The JDBC driver class name is (Microsoft driver): &quot;<code>com.microsoft.sqlserver.jdbc.SQLServerDriver</code>&quot;.</p>

<h2>Installation of MS SQL Server</h2>

<p>Microsoft SQL Server is commercial software and we cannot provide
generic installation instructions. We assume that Jena users wishing to use SQL Server
as a store have a correctly configured instance running. The Desktop Edition (MSDE 2000 Rel A) is
free and redistributable software. See <a href="http://www.microsoft.com/sql/msde/default.mspx">http://www.microsoft.com/sql/msde/default.mspx</a>
for download, installation and license information.</p>

<h2>Notes</h2>

<p>The single biggest limitation with the SQL Server 2000 driver implementation 
is that while a transaction is in progress inserting triples into a Model
then other processes will be blocked from reading from that Model. In other databases,
concurrent reads during a transaction are allowed. Whilst SQL Server does support ROW level 
locking, there seem to be situations in which it may still chose TABLE level locking
at the expense of reduced concurrency.<p>This does not affect SQL Server 2005.<p>&nbsp;
</body>
</html>
